package com.ruoyi.employee_zlw.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.employee_zlw.domain.ZlwEmployees;
import com.ruoyi.employee_zlw.service.IZlwEmployeesService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 员工信息管理Controller
 * 
 * @author zlw
 * @date 2025-06-12
 */
@Controller
@RequestMapping("/employee/employees")
public class ZlwEmployeesController extends BaseController
{
    private String prefix = "employee/employees";

    @Autowired
    private IZlwEmployeesService zlwEmployeesService;

    @RequiresPermissions("employee:employees:view")
    @GetMapping()
    public String employees()
    {
        return prefix + "/employees";
    }

    /**
     * 查询员工信息管理列表
     */
    @RequiresPermissions("employee:employees:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZlwEmployees zlwEmployees)
    {
        startPage();
        List<ZlwEmployees> list = zlwEmployeesService.selectZlwEmployeesList(zlwEmployees);
        return getDataTable(list);
    }

    /**
     * 导出员工信息管理列表
     */
    @RequiresPermissions("employee:employees:export")
    @Log(title = "员工信息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZlwEmployees zlwEmployees)
    {
        List<ZlwEmployees> list = zlwEmployeesService.selectZlwEmployeesList(zlwEmployees);
        ExcelUtil<ZlwEmployees> util = new ExcelUtil<ZlwEmployees>(ZlwEmployees.class);
        return util.exportExcel(list, "员工信息管理数据");
    }

    /**
     * 新增员工信息管理
     */
    @RequiresPermissions("employee:employees:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存员工信息管理
     */
    @RequiresPermissions("employee:employees:add")
    @Log(title = "员工信息管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZlwEmployees zlwEmployees)
    {
        return toAjax(zlwEmployeesService.insertZlwEmployees(zlwEmployees));
    }

    /**
     * 修改员工信息管理
     */
    @RequiresPermissions("employee:employees:edit")
    @GetMapping("/edit/{employeeId}")
    public String edit(@PathVariable("employeeId") String employeeId, ModelMap mmap)
    {
        ZlwEmployees zlwEmployees = zlwEmployeesService.selectZlwEmployeesByEmployeeId(employeeId);
        mmap.put("zlwEmployees", zlwEmployees);
        return prefix + "/edit";
    }

    /**
     * 修改保存员工信息管理
     */
    @RequiresPermissions("employee:employees:edit")
    @Log(title = "员工信息管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZlwEmployees zlwEmployees)
    {
        return toAjax(zlwEmployeesService.updateZlwEmployees(zlwEmployees));
    }

    /**
     * 删除员工信息管理
     */
    @RequiresPermissions("employee:employees:remove")
    @Log(title = "员工信息管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zlwEmployeesService.deleteZlwEmployeesByEmployeeIds(ids));
    }
}
